package com.tron.dobest.netty.socket;

import io.netty.channel.ChannelFuture;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import java.net.InetSocketAddress;

/**
 * 描述：
 *
 * @author TRON
 * @since 2020-06-18
 */
@Component
public class ChatServerStart implements ApplicationRunner {

    private  ChatServer chatServer;

    public ChatServerStart(ChatServer chatServer) {
        this.chatServer = chatServer;
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        ChatServer chatServer = new ChatServer();
        InetSocketAddress address = new InetSocketAddress("localhost", 9999);
        ChannelFuture future = chatServer.start(address);
        if (future.isSuccess()) {
            System.out.println("======netty端口9999启动成功======");
        }
    }
}
